// Source File Name:   CPInterfaceMethod.java

package com.vhly.classfile;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

// Referenced classes of package com.vhly.classfile:
//            CPEntry

public class CPInterfaceMethod
        extends CPEntry {

    private int nat_index;
    private int class_index;
    public static final int tag = 11;

    public CPInterfaceMethod() {
        class_index = 0;
        nat_index = 0;
    }

    public CPInterfaceMethod(int i, int j) {
        class_index = i;
        nat_index = j;
    }

    public int getClassIndex() {
        return class_index;
    }

    public int getSigIndex() {
        return nat_index;
    }

    public void setClassIndex(int i) {
        class_index = i;
    }

    public void setSigIndex(int i) {
        nat_index = i;
    }

    public void write(DataOutputStream dataoutputstream)
            throws IOException {
        dataoutputstream.write(11);
        dataoutputstream.writeShort(class_index);
        dataoutputstream.writeShort(nat_index);
    }

    public void read(DataInputStream datainputstream)
            throws IOException {
        class_index = datainputstream.readUnsignedShort();
        nat_index = datainputstream.readUnsignedShort();
    }

    public int getType() {
        return 11;
    }

    /**
     * 比较指定元素是否和自身相等
     *
     * @param e CPEntry
     * @return 0 equals -1 no
     */
    public boolean equalsTo(CPEntry e) {
        CPInterfaceMethod cpd = (CPInterfaceMethod) e;
        return cpd.class_index == this.class_index && cpd.nat_index == this.nat_index;
    }
}